@extends('layouts.app')

@section('content')
    <div class="container">
        <div class="row">
            @component('user.navpill',['info' => 'class=active'])

            @endcomponent

            <div class="col-md-9 col-md-offset-0">
                <div class="panel panel-default">
                    <div class="panel-body">
                        @if (session('status'))
                            <div class="alert alert-success">
                                {{ session('status') }}
                            </div>
                        @endif

                        <div class="col-md-12">
                            <ul class="nav nav-tabs">
                                <li role="presentation" class="active"><a href="#">早餐</a></li>
                                <li role="presentation" ><a href="{{ url('user/lunch') }}">午餐</a></li>
                                <li role="presentation" ><a href="{{ url('user/dinner') }}">晚餐</a></li>
                            </ul>
                        </div>

                        <div class="col-md-12">
                            <form class="navbar-form navbar-left" action="" method="get">
                                <div class="form-group">
                                    <label class="control-label">年份</label>
                                    <select class="form-control" name="year" id="year">
                                        @for($i = \Carbon\Carbon::today()->year; $i >= 2010; $i--)
                                            <option>{{ $i }}</option>
                                        @endfor
                                    </select>
                                </div>
                                <div class="form-group">
                                    <label class="control-label">月份</label>
                                    <select class="form-control" name="month" id="month">
                                        @for($i = 12; $i >=1; $i--)
                                            @if($i == \Carbon\Carbon::today()->month)
                                                <option selected>{{ str_pad($i, 2, '0', STR_PAD_LEFT) }}</option>
                                            @else
                                            <option>{{ str_pad($i, 2, '0', STR_PAD_LEFT) }}</option>
                                            @endif
                                        @endfor
                                    </select>
                                </div>
                                <div class="form-group">
                                    <button type="button" onclick="getEchart()" class="btn btn-info">查询</button>
                                </div>
                            </form>
                            {{--<form action="{{ url('user/breakfast/s') }}" class="navbar-form navbar-left" role="search">--}}
                                {{--<div class="form-group">--}}
                                    {{--<label for="startdate">开始日期</label>--}}
                                    {{--<input type="text" id="start_date" name="begin_date" class="form-control"--}}
                                           {{--value="{{ \Carbon\Carbon::today()->startOfMonth()->toDateString() }}"--}}
                                           {{--onclick="WdatePicker({--}}
                                           {{--dateFmt:'yyyy-MM-dd',--}}
                                           {{--maxDate:'#F{$dp.$D(\'end_date\')}' })">--}}
                                {{--</div>--}}
                                {{--<div class="form-group">--}}
                                    {{--<label for="enddate">结束日期</label>--}}
                                    {{--<input type="text" id="end_date" name="end_date" class="form-control"--}}
                                           {{--value="{{ \Carbon\Carbon::today()->endOfMonth()->toDateString() }}"--}}
                                           {{--onclick="WdatePicker({--}}
                                           {{--dateFmt:'yyyy-MM-dd',--}}
                                           {{--minDate:'#F{$dp.$D(\'start_date\')}'})">--}}
                                {{--</div>--}}
                                {{--<div class="form-group">--}}
                                    {{--<input type="checkbox" checked id="book" name="book">--}}
                                    {{--<label for="book">开餐 </label>--}}
                                {{--</div>--}}
                                {{--<div class="form-group">--}}
                                    {{--<input type="checkbox" checked id="cancel" name="cancel">--}}
                                    {{--<label for="cancel">停餐 </label>--}}
                                {{--</div>--}}
                                {{--<div class="form-group">--}}
                                    {{--<button type="submit" class="btn btn-info">查询</button>--}}
                                {{--</div>--}}
                            {{--</form>--}}
                        </div>

                        {{--<div class="col-md-12">--}}
                            {{--<p></p>--}}
                            {{--<table class="table">--}}
                                {{--<thead>--}}
                                {{--<tr>--}}
                                    {{--<th>开始日期</th>--}}
                                    {{--<th>结束日期</th>--}}
                                    {{--<th>用餐天数</th>--}}
                                {{--</tr>--}}
                                {{--</thead>--}}
                                {{--<tbody>--}}
                                {{--@if(isset($breakfasts))--}}
                                    {{--@foreach($breakfasts as $breakfast)--}}
                                        {{--<tr>--}}
                                            {{--<td>{{ $breakfast->begin_date or '' }}</td>--}}
                                            {{--<td>{{ $breakfast->end_date or '长期' }}</td>--}}
                                            {{--<td>{{ $breakfast->days or '' }}</td>--}}
                                        {{--</tr>--}}
                                    {{--@endforeach--}}
                                {{--@endif--}}
                                {{--</tbody>--}}
                            {{--</table>--}}
                            {{--@if (isset($breakfasts))--}}
                                {{--{{ $breakfasts->links() }}--}}
                            {{--@endif--}}
                        {{--</div>--}}
                    </div>
                </div>

                <div class="col-md-12" style="background-color: white;margin-top: 5px">
                    <div id="main" style="width: 700px;height: 500px"></div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('script')
    <script src="{{asset('My97DatePicker/WdatePicker.js')}}"></script>
    <script src="{{asset('js/echarts.min.js')}}"></script>
    <script>
        //初始化echarts实例
        var myChart = echarts.init(document.getElementById('main'));
        var layouts = [
            [[0, 0]],
            [[-0.25, 0], [0.25, 0]],
            [[0, -0.2], [-0.2, 0.2], [0.2, 0.2]],
            [[-0.25, -0.25], [-0.25, 0.25], [0.25, -0.25], [0.25, 0.25]]
        ];
        // svg图标的路径坐标
        var pathes = [
            'm89.038,37.502l-77.933,0c0,-14.156 11.475,-25.631 25.631,-25.631l26.672,0c14.155,0 25.63,11.475 25.63,25.631zm-78.563,31.389c0,10.627 8.613,19.238 19.238,19.238l40.719,0c10.624,0 19.237,-8.611 19.237,-19.238l-79.194,0zm78.57,-11.834c-1.956,0.348 -3.938,0.563 -5.884,0.697c-4.754,0.326 -9.834,0.275 -14.504,-1.029l-1.846,0c-5.616,2.992 -12.736,3.348 -18.826,2.102c-1.644,-0.336 -3.483,-1.377 -5.299,-2.102l-5.834,0c-3.781,1.492 -6.856,3.266 -11.26,2.523c-1.808,-0.305 -2.897,-1.287 -3.393,-2.523l-9.283,0c-2.888,0 -5.229,2.342 -5.229,5.229c0,2.889 2.342,5.23 5.229,5.23l74.31,0c2.889,0 5.229,-2.342 5.229,-5.23c0.001,-2.247 -1.419,-4.159 -3.41,-4.897zm-5.486,-3.596l5.816,1.451c1.145,0.285 2.305,-0.41 2.59,-1.555c0.286,-1.145 -0.41,-2.305 -1.555,-2.59l-6.55,-1.635c-0.478,-0.117 -0.979,-0.068 -1.424,0.139c-2.848,1.334 -6.426,2.773 -7.748,3.029c-0.97,-0.48 -3.167,-1.098 -8.795,-1.646c-0.32,-0.031 -0.645,0.01 -0.945,0.123l-3.685,1.357l-6.508,-1.439c-0.287,-0.063 -0.586,-0.068 -0.875,-0.01l-7.769,1.535l-6.646,0l-6.009,-1.512c-0.316,-0.078 -0.646,-0.084 -0.966,-0.018c-3.12,0.664 -6.85,1.391 -7.907,1.512c-0.457,-0.215 -1.408,-0.84 -2.002,-1.23c-2.061,-1.355 -3.423,-2.248 -4.835,-1.779c-0.559,0.172 -4.458,0.971 -7.905,1.641c-1.158,0.227 -1.913,1.348 -1.687,2.506c0.224,1.158 1.345,1.912 2.504,1.688c1.913,-0.373 6.063,-1.191 7.784,-1.605c0.471,0.252 1.273,0.779 1.793,1.121c1.894,1.244 3.02,1.949 4.156,1.949c1.15,0 6.002,-0.992 8.502,-1.52l5.786,1.455c0.17,0.043 0.345,0.064 0.521,0.064l7.119,0c0.139,0 0.277,-0.014 0.414,-0.041l7.536,-1.488l6.683,1.479c0.4,0.088 0.816,0.059 1.199,-0.082l3.811,-1.404c2.675,0.279 5.765,0.754 6.659,1.094c0.332,0.309 0.749,0.582 1.62,0.582c1.409,-0.001 3.998,-0.718 9.318,-3.171zm-75.589,-7.684c2.896,0.371 5.475,-0.289 8.687,1.111c3.211,1.4 4.64,3.678 8.577,3.992c6.3,0.453 9.799,-2.607 15.22,-3.938c2.058,-0.635 4.405,-0.758 6.752,-0.881c3.637,-0.453 6.916,-2.717 10.017,-3.404c3.898,-0.467 4.338,2.91 7.783,3.775c1.592,0.438 5.722,-0.564 7.547,-0.66c0.237,-0.014 0.522,-0.01 0.826,0.002c2.119,1.387 4.057,1.832 6.846,1.686c1.043,-0.057 1.372,1.234 2.649,0.645c0.696,-0.215 0.871,-1.24 0.992,-1.883c1.23,-0.154 2.26,-0.473 2.9,-1.061c3.53,-0.469 8.774,-0.984 9.609,-3.783c1.62,-4.008 -17.784,-0.107 -20.928,-0.203c-3.664,-0.068 -6.656,-2.264 -10.566,-2.059c-4.954,0.262 -8.811,1.512 -13.463,2.541c-8.014,1.729 -17.182,1.428 -24.73,2.088c-5.461,0.549 -6.71,-3.309 -11.212,-4.377c-2.375,-0.398 -10.731,-0.221 -11.623,2.703c-1.387,3.474 2.016,3.556 4.117,3.706z',
            'm58.696,5.306c-0.894,-0.894 -2.184,-1.347 -3.834,-1.347c-4.413,0 -11.115,3.192 -18.871,8.986c-0.276,0.207 -0.473,0.231 -0.832,0.272c-0.869,0.094 -1.95,0.214 -4.138,2.401c-1.807,1.808 -2.323,2.653 -2.737,3.333c-0.271,0.441 -0.482,0.79 -1.11,1.37c-1.183,1.096 -2.357,2.226 -3.491,3.359c-0.563,0.563 -1.119,1.129 -1.706,1.739c-0.387,0.389 -0.685,0.491 -1.135,0.647c-0.599,0.209 -1.347,0.469 -2.326,1.446c-0.448,0.449 -0.904,1.004 -1.396,1.701c-1.54,2.168 -1.961,3.184 -2.271,3.926c-0.198,0.474 -0.341,0.815 -0.765,1.36c-8.896,11.438 -12.258,20.707 -8.774,24.191c0.896,0.897 2.189,1.352 3.838,1.352l0.002,0c6.846,0 19.374,-7.926 31.172,-19.726c7.203,-7.204 13.067,-14.745 16.514,-21.233c3.497,-6.586 4.157,-11.479 1.86,-13.777zm-35.854,38.785c-1.93,-0.643 -4.307,-1.824 -6.696,-3.327c-1.057,-0.664 -2.101,-1.394 -3.107,-2.172c0.629,-0.883 1.299,-1.786 1.994,-2.693c1.03,0.53 2.063,1.12 3.072,1.754c2.383,1.5 4.478,3.132 5.896,4.598c1.416,1.464 1.551,2.139 1.566,2.27c-0.129,0.05 -0.698,0.246 -2.725,-0.43zm15.335,-12.445c-0.026,0.038 -0.237,0.18 -0.838,0.18c-0.53,0 -1.504,-0.114 -3.124,-0.651c-2.595,-0.865 -5.786,-2.451 -8.986,-4.466c-0.461,-0.288 -0.914,-0.593 -1.375,-0.904c1.302,-1.333 2.636,-2.64 3.968,-3.886c0.102,0.063 0.203,0.125 0.305,0.189c3.198,2.012 6.01,4.205 7.912,6.17c1.927,1.992 2.274,3.147 2.138,3.368zm9.302,-14.271c0,0 -0.115,0.074 -0.473,0.074c-0.38,0 -1.086,-0.084 -2.287,-0.483c-1.928,-0.643 -4.305,-1.823 -6.694,-3.328c-0.048,-0.03 -0.095,-0.06 -0.141,-0.09c1.111,-0.808 2.206,-1.568 3.263,-2.258c4.802,3.242 6.465,5.784 6.332,6.085z',
            'm432,0c-44.186,0 -80,35.816 -80,80l0,240l64,0l0,192l96,0l0,-432c0,-44.184 -35.817,-80 -80,-80zm-224,0c-8.838,0 -16,7.164 -16,16l0,112c0,4.418 -7.164,8 -16,8c-8.838,0 -16,-3.582 -16,-8l0,-112c0,-8.836 -7.164,-16 -16,-16c-8.837,0 -16,7.164 -16,16l0,112c0,4.418 -7.164,8 -16,8c-8.837,0 -16,-3.582 -16,-8l0,-112c0,-8.836 -7.164,-16 -16,-16c-8.837,0 -16,7.164 -16,16l0,112c0,4.418 -7.164,8 -16,8s-16,-3.582 -16,-8l0,-112c0,-8.836 -7.164,-16 -16,-16s-16,7.164 -16,16l0,112l0,32c0,14.159 12.529,22.055 26.502,32c17.605,12.532 37.498,28.318 37.498,64l0,256l96,0l0,-256c0,-35.682 19.893,-51.468 37.496,-64c13.973,-9.945 26.504,-17.841 26.504,-32l0,-32l0,-112c0,-8.836 -7.163,-16 -16,-16z',
            'm6.218,5.786c0.453,0 0.82,0.367 0.82,0.82c0,0.453 -0.367,0.82 -0.82,0.82c-0.453,0 -0.82,-0.367 -0.82,-0.82c0,-0.452 0.367,-0.82 0.82,-0.82zm0.033,3.085c1.103,0 1.997,0.894 1.997,1.997s-0.894,1.997 -1.997,1.997s-1.997,-0.894 -1.997,-1.997s0.894,-1.997 1.997,-1.997zm5.361,1.067c0.499,0 0.903,0.404 0.903,0.903c0,0.499 -0.404,0.903 -0.903,0.903c-0.499,0 -0.903,-0.404 -0.903,-0.903c0,-0.499 0.404,-0.903 0.903,-0.903zm6.235,2.544l0.017,-0.006c-0.895,-2.669 -2.403,-5.18 -4.527,-7.306c-2.074,-2.072 -4.511,-3.549 -7.107,-4.454c-0.21,-0.099 -0.442,-0.158 -0.688,-0.158c-0.9,0 -1.63,0.728 -1.63,1.629c0,0.728 0.482,1.338 1.141,1.547l-4.496,14.215l14.197,-4.489c0.206,0.664 0.818,1.149 1.549,1.149c0.899,0 1.628,-0.73 1.628,-1.629c0.001,-0.175 -0.033,-0.34 -0.084,-0.498zm-6.85,1.299c-0.055,-0.064 -0.109,-0.131 -0.169,-0.191c-1.009,-1.009 -2.644,-1.009 -3.654,0c-0.456,0.457 -0.705,1.04 -0.749,1.635l-4.601,1.456l3.955,-12.508c1.929,0.647 3.743,1.735 5.28,3.272c1.538,1.536 2.626,3.351 3.271,5.28c0.001,0 -3.333,1.056 -3.333,1.056z',
            'M936.857805 523.431322c0 0-42.065715-68.89513-88.786739-68.89513-46.68416 0-95.732122 71.223091-95.732122 71.223091s-44.28544-72.503296-93.440922-71.152538c-35.565466 0.977306-62.89705 30.882406-79.124275 64.06615L579.773747 790.800797c-3.253248 37.391565-5.677568 50.904371-12.002816 69.63497-6.651802 19.698688-19.544883 35.227341-31.650099 45.909606-14.30231 12.621414-29.59831 22.066586-45.854208 27.424563-16.28969 5.362074-30.098739 6.496973-51.536794 6.496973-19.498906 0-36.95104-2.963456-52.395418-8.850534-15.410586-5.887078-28.420403-14.313984-39.034573-25.246003-10.613146-10.930995-18.757939-24.08151-24.435507-39.525171-5.676544-15.443763-8.532685-40.195482-8.532685-59.270963l0-26.232454 74.435273 0c0 24.644301-0.17705 64.452915 8.81408 77.006848 9.02697 12.515021 22.756147 18.092032 41.148826 18.791014 16.728678 0.636518 30.032179-8.061645 30.032179-8.061645s11.922022-10.5472 14.992077-19.756954c2.674995-8.025805 3.565363-22.180147 3.565363-22.180147s2.080461-21.789286 2.080461-34.234675L489.399906 514.299369c-16.678502-18.827776-43.801395-61.938688-82.756096-60.927693-54.699008 1.419366-100.422144 70.059622-100.422144 70.059622s-56.065126-70.059622-93.440922-70.059622c-37.376717 0-91.077939 70.059622-91.077939 70.059622S105.343488 156.737741 476.742042 119.363584l53.70327-74.714624 51.373056 74.714624C964.889395 142.740992 936.857805 523.431322 936.857805 523.431322z',
            'M533.504 268.288q33.792-41.984 71.68-75.776 32.768-27.648 74.24-50.176t86.528-19.456q63.488 5.12 105.984 30.208t67.584 63.488 34.304 87.04 6.144 99.84-17.92 97.792-36.864 87.04-48.64 74.752-53.248 61.952q-40.96 41.984-85.504 78.336t-84.992 62.464-73.728 41.472-51.712 15.36q-20.48 1.024-52.224-14.336t-69.632-41.472-79.872-61.952-82.944-75.776q-26.624-25.6-57.344-59.392t-57.856-74.24-46.592-87.552-21.504-100.352 11.264-99.84 39.936-83.456 65.536-61.952 88.064-35.328q24.576-5.12 49.152-1.536t48.128 12.288 45.056 22.016 40.96 27.648q45.056 33.792 86.016 80.896z',
            'M741.06368 733.310464c8.075264-29.262438 20.615373-40.632422 14.64105-162.810061C966.089728 361.789952 967.93897 72.37847 967.855002 54.693683c0.279347-0.279347 0.418509-0.419533 0.418509-0.419533s-0.17705-0.00512-0.428749-0.00512c0-0.251699 0-0.428749 0-0.428749s-0.139162 0.14633-0.418509 0.425677c-17.695744-0.083866-307.10784 1.760051-515.833958 212.142592-122.181632-5.984256-133.55305 6.563533-162.815693 14.644531C235.35063 295.798886 103.552614 436.975309 90.630758 486.076621c-12.921856 49.105408 39.634227 56.859034 58.579558 58.581197 18.953421 1.724314 121.471386-9.475789 130.09111 4.309094 0 0 16.367411 11.200102 17.226035 41.346662 0.850432 29.796659 15.173222 71.354163 37.123994 97.267302-0.028672 0.027648-0.05632 0.054272-0.083866 0.074752 0.158618 0.13097 0.316211 0.261939 0.474829 0.390861 0.129946 0.149402 0.261939 0.319283 0.393011 0.468685 0.019456-0.019456 0.04608-0.049152 0.075776-0.075674 25.918362 21.961216 67.477504 36.272128 97.269248 37.122458 30.149837 0.859546 41.354547 17.234534 41.354547 17.234534 13.779354 8.608051 2.583962 111.122842 4.302131 130.075546 1.727386 18.95168 9.477222 71.498445 58.579558 58.576077C585.12896 918.526771 726.311117 786.734182 741.06368 733.310464zM595.893555 426.206003c-39.961702-39.965184-39.961702-104.75991 0-144.720077 39.970918-39.96928 104.768307-39.96928 144.730112 0 39.970918 39.960064 39.970918 104.75479 0 144.720077C700.661862 466.171187 635.864474 466.171187 595.893555 426.206003zM358.53312 769.516032c-31.923302-4.573184-54.890394-18.410291-71.41847-35.402342-16.984474-16.526438-30.830387-39.495475-35.405824-71.420621-4.649062-28.082586-20.856832-41.167565-38.76649-38.763827-17.906586 2.40681-77.046886 66.714419-80.857805 89.475891-3.80887 22.752154 29.271859 12.081152 46.424166 27.654861 17.151283 15.590093-2.139853 61.93664-14.733107 86.845952-6.441984 12.735078-10.289766 26.42176-4.22953 33.76087 7.346586 6.070272 21.03593 2.222592 33.769472-4.220109 24.912384-12.585677 71.258829-31.872922 86.842368-14.731469 15.583539 17.160806 4.911002 50.229965 27.674419 46.419251 22.754099-3.807744 87.065395-62.946611 89.466163-80.85248C399.70857 790.374093 386.627072 774.166938 358.53312 769.516032z',
            'M848.794624 939.156685 571.780416 939.156685 571.780416 653.17123l341.897539 0 0 221.100654C913.677926 909.960704 884.482867 939.156685 848.794624 939.156685zM571.780403 318.743552c-11.861606-3.210138-31.443354-8.36864-39.829709-16.176435-0.596582-0.561766-1.016218-1.246413-1.613824-1.841971-0.560845 0.596582-1.016218 1.280205-1.613824 1.841971-8.386355 7.807795-15.96631 12.965274-27.827917 16.176435l0 263.544325L141.030675 582.287877 141.030675 355.202884c0-35.687834 29.195059-64.882688 64.883302-64.882688l150.649125 0c-16.984474-9.525965-32.846438-20.56233-46.111027-32.932045-60.250624-56.144691-71.129907-137.062605-24.283034-180.767027 19.615539-18.264986 46.252237-27.124736 75.026739-27.124736 39.933133 0 83.972915 17.070797 118.995968 49.706086 20.353331 18.983322 37.722624 43.405619 50.145075 69.056819 12.457267-25.6512 29.791744-50.074419 50.180915-69.056819 35.022029-32.63529 79.062835-49.706086 118.994944-49.706086 28.74071 0 55.410176 8.860774 75.025715 27.124736 46.882611 43.704422 35.96759 124.622336-24.283034 180.767027-13.264589 12.368691-29.127578 23.40608-46.111027 32.932045l144.649234 0c35.688243 0 64.882278 29.195981 64.882278 64.882688l0 227.084948L571.780416 582.287833 571.780416 318.743508zM435.064218 147.625267c-21.476966-19.965747-49.094144-31.913882-73.868288-31.913882-7.404954 0-21.125018 1.211597-29.863322 9.386803-2.000691 1.824563-8.070144 7.439462-8.070144 21.369754 0 15.650406 8.492749 40.24873 32.319386 62.477926 29.124506 27.12576 77.202432 47.601152 111.76704 47.601152 12.176794 0 16.492237-2.666701 16.527053-2.702541C489.524736 242.54505 475.664486 185.453773 435.064218 147.625267zM577.78135 254.790963c0 0 0.034816-0.034816 0.069632-0.034816 0.807424 0 5.50871 1.790771 15.509914 1.790771 34.564608 0 82.64151-20.47529 111.76704-47.601152 23.826637-22.229299 32.283546-46.810112 32.283546-62.442189 0-13.930291-6.033613-19.562496-8.035328-21.404467-8.77312-8.17623-22.457344-9.386803-29.864346-9.386803-24.808038 0-52.390298 11.948134-73.867264 31.913882C585.325466 185.208218 571.358822 241.73865 577.78135 254.790963zM500.89513 939.156685 205.914017 939.156685c-35.688243 0-64.883302-29.195981-64.883302-64.883712L141.030714 653.17123l359.864462 0L500.895177 939.15666z'
        ];
        var colors = [
            '#c4332b', '#16B644', '#6862FD', '#FDC763'
        ];

        function getVirtulData(year) {
            year = year || '2017';
            var date = +echarts.number.parseDate(year + '-01-01');
            var end = +echarts.number.parseDate((+year + 1) + '-01-01');
            var dayTime = 3600 * 24 * 1000;
            var data = [];
            for (var time = date; time < end; time += dayTime) {
                var items = [];
                // pathes.length=4, eventCount:0~4随机整数
                var eventCount = Math.round(Math.random() * pathes.length);
                for (var i = 0; i < eventCount; i++) {
                    items.push(Math.round(Math.random() * (pathes.length - 1)));
                }
                // data结果形式：["2017-11-11", "0|1|2|2"]
                data.push([
                    echarts.format.formatTime('yyyy-MM-dd', time),
                    items.join('|') // items.join('|') 把数组中的所有元素转换为一个字符串用|分隔
                ]);
            }
            return data;
        }

        function renderItem(params, api) {
            // api.value(0) 取出当前 dataItem 中第一个维度的数值。
            // api.coord(...) 将数值在当前坐标系中转换成为屏幕上的点的像素值。
            var cellPoint = api.coord(api.value(0));

            // 当前坐标系的包围盒
            var cellWidth = params.coordSys.cellWidth;
            var cellHeight = params.coordSys.cellHeight;

            // api.value(1) 取出当前 dataItem 中第二个维度的数值。
            var value = api.value(1);

            /**
             * a() && b() :如果执行a()后返回true，则执行b()并返回b的值；如果执行a()后返回false，则整个表达式返回a()的值，b()不执行；
             * a() || b() :如果执行a()后返回true，则整个表达式返回a()的值，b()不执行；如果执行a()后返回false，则执行b()并返回b()的值；
             * && 优先级高于 ||
             */
            var events = value && value.split('|');  //value.split('|') 把一个字符串分割成字符串数组

            if (isNaN(cellPoint[0]) || isNaN(cellPoint[1])) {
                return;
            }

            var group = {
                // 一组图形元素
                type: 'group',
                // echarts.util.map 这个帮忙方法其行为和Array.prototype.map一样
                children: echarts.util.map(layouts[events.length - 1], function (itemLayout, index) {
                    return {
                        type: 'path',
                        shape: {
                            pathData: pathes[index +1],//pathes[events[index]],
                            x: -8,
                            y: -8,
                            width: 16,
                            height: 16
                        },
                        // 绝对位置，相对于容器左侧 , 上侧
                        position: [
                            cellPoint[0] + echarts.number.linearMap(itemLayout[0], [-0.5, 0.5], [-cellWidth / 2, cellWidth / 2]),
                            cellPoint[1] + echarts.number.linearMap(itemLayout[1], [-0.5, 0.5], [-cellHeight / 2 + 20, cellHeight / 2])
                        ],
                        // 用 api.style(...) 函数，他能得到 series.itemStyle.normal 中定义的样式信息，以及视觉映射的样式信息。
                        // 也可以用这种方式覆盖这些样式信息：api.style({fill: 'green', stroke: 'yellow'})。
                        style: api.style({
                            fill: colors[index + 1]//colors[events[index]]
                        })
                    };
                }) || []
            };

            group.children.push({
                type: 'text',
                style: {
                    x: cellPoint[0],
                    y: cellPoint[1] - cellHeight / 2 + 15,
                    text: echarts.format.formatTime('dd', api.value(0)),
                    fill: '#777',
                    textFont: api.font({fontSize: 14})
                }
            });
//            console.log(group);
            return group;

        }

        function getEchart() {
            //加载动画
            myChart.showLoading();

            var year = $("#year").val();
            var month = $("#month").val();
            var url = "{{ url('user/breakfast/s') }}";
            url = url+'?year='+year+'&month='+month;

            $.get(url).done(function (data) {
                option = {
                    //提示框组件
                    tooltip: {
                    },
                    //日历坐标系组件
                    calendar: [{
                        //组件离容器左侧的距离'20%','left', 'center', 'right', 'middle'。
                        left: 'center',
                        //组件离容器上侧的距离'20%','left', 'center', 'right', 'middle'。
                        top: 'middle',
                        //日历每格框的大小，可设置单值或数组 第一个元素是宽 第二个元素是高。 支持设置自适应：auto, 默认为高宽均为20
                        cellSize: [70, 70],
                        //设置日历坐标中 年的样式
                        yearLabel: {
                            show: true,
                            margin: 40,
                        },
                        //日历坐标的布局朝向 ,水平：'horizontal'，垂直：'vertical'
                        orient: 'vertical',
                        dayLabel: {
                            margin: 20,
                            firstDay: 0,
                            nameMap: ['星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六']
                        },
                        monthLabel: {
                            show: true,
                            nameMap: 'cn'
                        },
                        range: data.month
                    }],
                    //series系列列表。每个系列通过 type 决定自己的图表类型
                    series: [{
                        //custom 系列需要开发者自己提供图形渲染的逻辑
                        type: 'custom',
                        //该系列使用的坐标系
                        coordinateSystem: 'calendar',

                        //开发者自己提供图形渲染的逻辑
                        renderItem: renderItem,

                        //使用 dimensions 定义 data 每个维度的信息
                        // 定义了每个维度的名称。这个名称会被显示到默认的 tooltip 中。
                        //dimensions: ['date', 'open', 'close', 'highest', 'lowest'],
                        dimensions: [null, // 如果此维度不想给出定义，则使用 null 即可
                            {type: 'ordinal'} // 只定义此维度的类型。'ordinal' 表示离散型，一般文本使用这种类型。如果类型没有被定义，会自动猜测类型。
                        ],
//                        data: getVirtulData(2017)
                        data: data.data
                    }]
                };

                // 清空画布，防止缓存
                myChart.clear();
                //隐藏加载动画。
                myChart.hideLoading();
                // 使用刚指定的配置项和数据显示图表。
                myChart.setOption(option);
            });
        }

    </script>
@endsection